{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "6d121c7c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "关于页面-手表版.png\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "from PIL import Image\n",
    "\n",
    "\n",
    "def change_img_size(file_path, new_width=1950, new_height=2560):\n",
    "    # 打开图像文件\n",
    "    image = Image.open(file_path)\n",
    "    \n",
    "    # 调整图像大小\n",
    "    resized_image = image.resize((new_width, new_height))\n",
    "    \n",
    "    # 获取文件名和扩展名\n",
    "    file_name, file_ext = os.path.splitext(os.path.basename(file_path))\n",
    "    \n",
    "    # 生成新的文件名\n",
    "    new_file_name = f'new_{file_name}{file_ext}'\n",
    "    new_file_path = os.path.join(os.path.dirname(file_path), new_file_name)\n",
    "    \n",
    "    # 保存调整后的图像\n",
    "    resized_image.save(new_file_path)\n",
    "\n",
    "def process_images_on_desktop():\n",
    "    # 获取桌面路径\n",
    "    desktop_path = r\"E:\\minimote\\Desktop\"\n",
    "    \n",
    "    # 遍历桌面路径下的所有文件\n",
    "    for filename in os.listdir(desktop_path):\n",
    "        # 检查是否为图片文件\n",
    "        if filename.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp', '.gif')) and filename.startswith('new_') == False:\n",
    "            file_path = os.path.join(desktop_path, filename)\n",
    "            # 处理图片\n",
    "            change_img_size(file_path)\n",
    "            print(filename)\n",
    "\n",
    "# 调用函数处理桌面图片\n",
    "process_images_on_desktop()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
